//solution 1:
const data = fs.readFileSync(`${__dirname}/dev-data/data.json`, 'utf-8')
const dataObj = JSON.parse(data)

//which will block the pipe

//solution 2:
const fs = require(fs)
const readable = fs.createReadStream('test-file.txt');
readable.on('data',chunk=>{
    res.write(chunk)
})
readable.on('end',()=>{
    console.log("ENDING...")
    res.end()
})
readable.on('error',()=>{
    
    res.statusCode = 500
    res.end()
})
server.listen(8000,'127.0.0.1',()=>{
    console.log("TESTING")
})



//solution 3:
const readable1 = fs.createReadStream('test-file.txt')
readable.pipe(res)

